﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ChipsPanel : MonoBehaviour
{

    public List<GameObject> chipBtnList;
    public List<UISprite> chipSpriteList;
    public List<GameObject> selectedStatusList;

    EginXTJ xtj = EginXTJ.Instance;
    void Start()
    {
        long num = 0;
        if (xtj.roundType == 1 || xtj.roundType == 3)
        {
            //设置筹码图片
            for (int i = 0; i < xtj.chipList.Count; i++)
            {
                num = xtj.chipList[i];
                chipSpriteList[i].spriteName = num.ToString();
            }
        }
        else if (xtj.roundType == 4)
        {
            //设置筹码图片
            for (int i = 0; i < xtj.chipList.Count; i++)
            {
                num = xtj.chipList[i];
                chipSpriteList[i].spriteName = num.ToString();
            }
        }
        for (int i = 0; i < chipBtnList.Count; i++)
        {
            UIEventListener.Get(chipBtnList[i]).onClick = ButtonClick;
        }
    }

    public void ButtonClick(GameObject button)
    {
        HideSelectedStatus();
        if (button.name == "Chip1")
        {
            selectedStatusList[0].SetActive(true);
            xtj.currentChip = xtj.chipList[0];

        }
        else if (button.name == "Chip2")
        {
            selectedStatusList[1].SetActive(true);
            xtj.currentChip = xtj.chipList[1];
        }
        else if (button.name == "Chip3")
        {
            selectedStatusList[2].SetActive(true);
            xtj.currentChip = xtj.chipList[2];
        }
        else if (button.name == "Chip4")
        {
            selectedStatusList[3].SetActive(true);
            xtj.currentChip = xtj.chipList[3];
        }
        else if (button.name == "Chip5")
        {
            selectedStatusList[4].SetActive(true);
            xtj.currentChip = xtj.chipList[4];
        }
        Debug.Log("当前所选的筹码是：" + xtj.currentChip);
    }


    public void HideSelectedStatus()
    {
        for (int i = 0; i < selectedStatusList.Count; i++)
        {
            selectedStatusList[i].SetActive(false);
        }
    }
}
